import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PaymentWayVO, PaymentWayForm, PaymentWayQuery } from '@/api/retail/paymentWay/types';

/**
 * 查询收款方式列表
 * @param query
 * @returns {*}
 */

export const listPaymentWay = (query?: PaymentWayQuery): AxiosPromise<PaymentWayVO[]> => {
  return request({
    url: '/retail/paymentWay/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询收款方式详细
 * @param id
 */
export const getPaymentWay = (id: string | number): AxiosPromise<PaymentWayVO> => {
  return request({
    url: '/retail/paymentWay/' + id,
    method: 'get'
  });
};

/**
 * 新增收款方式
 * @param data
 */
export const addPaymentWay = (data: PaymentWayForm) => {
  return request({
    url: '/retail/paymentWay',
    method: 'post',
    data: data
  });
};

/**
 * 修改收款方式
 * @param data
 */
export const updatePaymentWay = (data: PaymentWayForm) => {
  return request({
    url: '/retail/paymentWay',
    method: 'put',
    data: data
  });
};

/**
 * 删除收款方式
 * @param id
 */
export const delPaymentWay = (id: string | number | Array<string | number>) => {
  return request({
    url: '/retail/paymentWay/' + id,
    method: 'delete'
  });
};
